package edu.hwadee.BEIS.repository;

import java.util.Date;
import java.util.Set;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import edu.hwadee.BEIS.entity.SchoolBasicInfor;
import edu.hwadee.BEIS.entity.WholeSchoolTrainingBase;

public interface WholeSchoolTrainingBaseRepository extends JpaRepository<WholeSchoolTrainingBase, Integer> {
	
	/*
	 * 根据全校实训基地的ID查询全校实训基地
	 */
	WholeSchoolTrainingBase findByWholeSchoolTrainingbaseId(Integer wholeSchoolTrainingbaseId);
	
	/*
	 * 根据学校基本信息查询全校实训基地，并按修改时间排序
	 */
	Page<WholeSchoolTrainingBase> findBySchoolBasicInOrderByModifyTimeDesc(Pageable pageable, Set<SchoolBasicInfor> schoolBasic);
	
	/*
	 * 根据学校基本信息和区县审核状态查询全校实训基地，并按修改时间排序
	 */
	Page<WholeSchoolTrainingBase> findBySchoolBasicInAndCountyAuditStatusIsOrderByModifyTimeDesc(Pageable pageable, Set<SchoolBasicInfor> schoolBasic, Short countyAuditStatus);

	/*
	 * 根据全校实训基地的学校基本信息的belongID或区县审核状态为通过查询全校实训基地，并按照修改时间排序，去重
	 */
	Page<WholeSchoolTrainingBase> findDistinctBySchoolBasic_BelongIdOrCountyAuditStatusOrderByModifyTimeDesc(Pageable pageable,String belongId, Short countyAuditStatus);
	
	/*
	 * 根据全校实训基地表的学校基本信息的belongID或区县审核状态为通过，同时根据市局审核状态查询全校实训基地，并按照修改时间排序，去重
	 */
	Page<WholeSchoolTrainingBase> findDistinctBySchoolBasic_BelongIdAndCityAuditStatusOrCountyAuditStatusAndCityAuditStatusOrderByModifyTimeDesc(Pageable pageable,String belongId, Short cityAuditStatus1,Short countyAuditStatus,Short cityAuditStatus2);

	Set<WholeSchoolTrainingBase> findBySchoolBasicIsAndCountyAuditStatusIsAndCityAuditStatusIsAndModifyTimeAfterOrderByModifyTime(SchoolBasicInfor schoolBasicInfor, Short county, Short city, Date from);
}
